#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],d[100005],v[100005],p[100005],vis[100005],cnt=1,m,l,vm,ans,ans2;
void solve(){
    ans=0,ans2=0;
    cin>>n>>m>>l>>vm;
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
    }
    for(int i=1;i<=n;i++) scanf("%lld",&p[i]);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(d[i]<=p[j]){
                double v1=sqrt((p[j]-d[i])*2*a[i]+v[i]*v[i]);
                if(v1>vm){
                    vis[j]=1,ans++;
                    break;
                }
            }
        }
    }
    for(int i=1;i<=m;i++){
        if(vis[i]==0) ans2++;
    }
    cout<<ans<<" "<<ans2<<'\n';
}
int main(){
    freopen("detect2.in","r",stdin);
    freopen("detect2.out","w",stdout);
    long long t;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

